import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)


// import register from "../pages/register/register.vue"
// import login from "../pages/login/login.vue"
// import index from "../pages/index/index.vue"
// import list from "../pages/list/list.vue"
// import detail from "../pages/detail/detail.vue"
// import search from "../pages/search/search.vue"

// //二级路由
// import home from "../pages/home/home.vue"
// import cate from "../pages/cate/cate.vue"
// import shop from "../pages/shop/shop.vue"
// import mine from "../pages/mine/mine.vue"

const routes = [
  {
    path:'/register',
    component:()=> Promise.resolve(import('../pages/register/register.vue')),
    meta:{
      title:'注册',
      back:true
    }
  },
  {
    path:'/login',
    component:()=> Promise.resolve(import('../pages/login/login.vue')),
    meta:{
      title:'登录',
      register:true
    }
  },
  {
    path:'/index',
    component:()=> Promise.resolve(import('../pages/index/index.vue')),
    children:[
      {path:'home',
      component:()=> Promise.resolve(import('../pages/home/home.vue'))
      ,meta:{
        title:'首页'
      }},
      {path:'shop',component:()=> Promise.resolve(import('../pages/shop/shop.vue'))
      ,meta:{
        title:'购物车'
      }},
      {path:'mine',component:()=> Promise.resolve(import('../pages/mine/mine.vue')),meta:{
        title:'个人中心'
      }},
      {path:'cate',component:()=> Promise.resolve(import('../pages/cate/cate.vue')),meta:{
        title:'分类'
      }},
    ]
  },
  {
    path:'/list',
    component:()=> Promise.resolve(import('../pages/list/list.vue')),
    meta:{
      title:'商品列表',
      back:true

    }
  },
  {
    path:'/detail',
    name:'详情',
    component:()=> Promise.resolve(import('../pages/detail/detail.vue')),
    meta:{
      title:'商品详情',
      back:true

    }
  },
  {
    alias:'/s',//别名
    name:'搜索',
    path:'/search',
    component:()=> Promise.resolve(import('../pages/search/search.vue')),
    meta:{
      title:'搜索',
      back:true
    }
  },
  {
    path:'*',
    redirect:'/login'


  }

  
]



const router = new VueRouter({
  routes
})

export default router
